package com.turing.data.service.impl;

import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.turing.data.dao.AnswerMapper;
import com.turing.data.model.dto.Answer;
import com.turing.data.service.AnswerService;

/**
 * @author Maven
 * @Description
 * @date 2020/10/15 18:48
 * @Copyright
 */
@Service
public class AnswerServiceImpl implements AnswerService {

    @Autowired
    AnswerMapper answerMapper;

    @Override
    public Answer getAnswerByTemplateId(String templateId) {
        return new LambdaQueryChainWrapper<>(answerMapper)
                .eq(Answer::getTemplateId, templateId)
                .one();
    }

    @Override
    public void insertAnswer(Answer answer) {
        answerMapper.insert(answer);
    }

    @Override
    public void updateAnswer(Answer answer) {
        answerMapper.updateById(answer);

    }
}
